import core
from world import world
import mesh
from gameflags import *

class myCube(mesh.cube):
    def leftAction(self, event):
        if event == 316: # Left Arrow Key
            cube.setRotation("x",5.0)
    def rightAction(self, event):
        if event == 318: # Right Arrow Key
            cube.setRotation("x",-5.0)
    def upAction(self, event):
        if event == 317: # Right Arrow Key
            cube.setRotation("y",-5.0)
    def downAction(self, event):
        if event == 319: # Right Arrow Key
            cube.setRotation("y",-5.0)
    def allocateEvents(self):
        self.registerEvent(self.leftAction)
        self.registerEvent(self.rightAction)
        self.registerEvent(self.upAction)
        self.registerEvent(self.downAction)

cube = myCube()
cube.selected = True
cube.renderType.add(POINTS)
cube.renderType.add(EDGES)

myworld = world()
myworld.addMesh(cube)
myworld.camera.setPosition([10,0,0])
myworld.camera.lookup = [0,0,1]

reactor = core.reactor(myworld)
reactor.factory.setSize([800,600])
reactor.factory.setTitle("Darkcore")
reactor.run()